package com.zzz.robot201.utils;

import android.graphics.drawable.Drawable;

import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;

import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.ResourceUtils;
import com.blankj.utilcode.util.StringUtils;

public class UIUtils {
    private static long lastClickTime = 0;//上次点击的时间
    private static int spaceTime = 500;//时间间隔

    /**
     * 防快速点击
     *
     * @return true 不可通过， false 可通过
     */
    public static boolean isFastClick() {
        long currentTime = System.currentTimeMillis();//当前系统时间
        boolean isAllowClick;//是否允许点击
        if (currentTime - lastClickTime > spaceTime) {
            isAllowClick = false;
        } else {
            isAllowClick = true;
        }
        lastClickTime = currentTime;
        return isAllowClick;
    }


    public static String getString(@StringRes int resId){
        return StringUtils.getString(resId);
    }

    public static int getColor(@ColorRes int resId){
        return ColorUtils.getColor(resId);
    }

    public static Drawable getDrawable(@DrawableRes int resId){
        return ResourceUtils.getDrawable(resId);
    }
}
